package com.yayo.mangement.controller.system;

import com.yayo.mangement.dto.SysMenuDTO;
import com.yayo.mangement.facade.SysMenuFacade;
import com.yayo.mangement.paging.Paging;
import com.yayo.mangement.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 
 * @author: Yayo
 * @date: 2020-07-16 08:04:18
 */
@RestController
@RequestMapping("/api/sysMenu")
public class SysMenuController{

    @Autowired
    private SysMenuFacade sysMenuFacade;

    /**
     * 列表查询，不分页
     * @return
     */
    @GetMapping("/paging")
    public Response<Paging<SysMenuDTO>> paging(){
        return sysMenuFacade.paging();
    }

    /**
    * 列表查询
    */
    @GetMapping("/list")
    public Response<List<SysMenuDTO>> list(){
        return sysMenuFacade.list();
    }

    /**
    *  查询详情
    * @param id 查询条件：主键
    * @return
    */
    @GetMapping("/detail/{id}")
    public Response<SysMenuDTO> detail(@PathVariable Long id){
        return sysMenuFacade.detail(id);
    }

    /**
    *  新增
    * @param sysMenuDTO
    * @return
    */
    @PostMapping("/create")
    public Response create(@RequestBody SysMenuDTO sysMenuDTO){
        return sysMenuFacade.create(sysMenuDTO);
    }

    /**
     *  修改
     * @param sysMenuDTO
     * @return
     */
    @PutMapping("/update")
    public Response update(@RequestBody SysMenuDTO sysMenuDTO){
        return sysMenuFacade.update(sysMenuDTO);
    }

    /**
    *  删除
    * @param id 主键
    * @return
    */
    @DeleteMapping("/delete")
    public Response delete(@RequestBody Long id){
        return sysMenuFacade.delete(id);
    }


}